package 继承;

/*
CSDN链接：
https://blog.csdn.net/Etenal_/article/details/144947078?fromshare=blogdetail&sharetype=blogdetail&sharerId=144947078&sharerefer=PC&sharesource=Etenal_&sharefrom=from_link
 */

public class QWQ {
    public static void main(String[] args) {

        Child child = new Child("cxk", 18);
        child.setName("kk");
        System.out.println(child.getName() + " " + child.getAge());
    }
}

class Parent {
    private String name;

    public Parent(String name) {
        this.name = name;
    }

    public Parent() {
    }


    protected void test() {
        System.out.println("parent");
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

}


class Child extends Parent {
    private int age;

    public Child(String name, int age) {
        super(name);
        this.age = age;
    }

    public Child() {
    }


    @Override
    public void test() {
        System.out.println("child");
    }


    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

}